﻿using System.Collections.Generic;
using System.Linq;
using Devbridge.IPolice.DataContracts;
using Devbridge.IPolice.DomainModel;

namespace Devbridge.IPolice.RepositoriesMock
{
    public class DepartmentRepositoryMock : IDepartmentRepository
    {
        private readonly IList<Department> departments;

        public DepartmentRepositoryMock()
        {
            departments = new List<Department>();

            departments.Add(new Department { });
            departments.Add(new Department { });
            departments.Add(new Department { });
        }

        public Department GetById(int id)
        {
            Department crime = AllQuery().FirstOrDefault(p => p.Id == id);

            return crime;
        }

        public IQueryable<Department> AllQuery()
        {
            return departments.AsQueryable();
        }

        public void Remove(Department entity)
        {
            departments.Remove(entity);
        }

        public void Save(Department entity)
        {
            departments.Add(entity);
        }
    }
}